#!/bin/bash

set -ex

if [ ! -d `pwd`/build ]; then
    mkdir `pwd`/build
fi 

if [ ! -d `pwd`/lib ]; then
    mkdir `pwd`/lib
fi 

rm -rf `pwd`/build/*

cd `pwd`/build &&
    cmake .. &&
    make

cd ..

# 把头文件拷贝到 /usr/include/mymuduo so库拷贝到/usr/lib下

cp -r `pwd`/lib/* /usr/lib/

if [ ! -d /usr/include/rpc ]; then
    mkdir /usr/include/rpc
fi 

cp -r `pwd`/src/include/* /usr/include/rpc/